/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ppsa.dao;

import com.ppsa.bean.AreaBean;
import com.ppsa.bean.CargoBean;
import com.ppsa.bean.EmpleadoBean;
import com.ppsa.bean.PerfilBean;
import com.ppsa.bean.ReunionBean;
import com.ppsa.bean.TareaBean;
import com.ppsa.common.Constantes;
import java.util.List;


import java.sql.DriverManager;
import java.sql.ResultSet;
import java.util.ArrayList;

/**
 *
 * @author AdminTdp
 */
public class CargoDao extends AccesoDao {

    public CargoDao() throws AccesoDaoException {
        super();
    }

    public List<CargoBean> listarCargo( String strpv_codigoArea ) throws Exception {
        List<CargoBean> lstL_cargo = new ArrayList<CargoBean>();

        CargoBean objL_cargo = null;
        //TareaBean objL_tarea = null;
        try {
            //this.objPt_conn = objPt_dataSource.getConnection();
            this.objPt_conn = DriverManager.getConnection(strpv_conexionUrl);
            String strl_procedure = "{ call ppsa_sp_listarCargoArea(?) }";

            objPt_cstmt = objPt_conn.prepareCall(strl_procedure);
            objPt_cstmt.setString(1, strpv_codigoArea);
            objPt_rs = objPt_cstmt.executeQuery();
            while( objPt_rs.next() ) {
                objL_cargo = new CargoBean();
                objL_cargo.setStrpv_codigoCargo(objPt_rs.getString("ID"));
                objL_cargo.setStrpv_nombreCargo(objPt_rs.getString("NOMBRE"));
           
                lstL_cargo.add(objL_cargo);
            }
        } catch ( Exception ex ) {
            ex.printStackTrace();
        } finally {
            closeCallableStatement(objPt_cstmt);
            closeResultSet(objPt_rs);
            closeConnection(objPt_conn);
        }
        return lstL_cargo;
    }
}
